package singleton

import (
	"sync"
	"time"
)

// 以配置管理场景为例讲单例模式

type AppConfig struct {
	APIEndpoint string
	Timeout time.Duration
}

var (
	instance *AppConfig
	once sync.Once
)

func GetInstance() *AppConfig {
	once.Do(func() {
		instance = &AppConfig{
			APIEndpoint: "https://api.example.com",
			Timeout: 5 * time.Second,
		}
	})
	return instance
}
